List comprehensions are faster


In [1]:
symbols = list('aeiou1234567890')
symbols


Out[1]:
['a', 'e', 'i', 'o', 'u', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0']

In [2]:
%%timeit

ord_list = []
for i in symbols:
    ord_list.append(ord(i))


1.56 µs ± 2 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

List comprehensions are slightly faster


In [4]:
%%timeit

ord_list1 = [ord(i) for i in symbols]


1.13 µs ± 3.62 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

In [ ]: